package com.chuji.crmcj.bean;


import com.chuji.crmcj.utils.PinYinUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GoodMan implements Comparable<GoodMan> {

    public String mName;
    public String mPinyin;

    public GoodMan(String name) {
        mName = name;
        mPinyin = PinYinUtil.toPinyin(name);
    }

    @Override
    public int compareTo(GoodMan another) {
        return mPinyin.compareTo(another.mPinyin);
    }

    public String getFast(String name) {
        Pattern p = Pattern.compile("[0-9]*");
        Matcher m = p.matcher(name);
        if (m.matches()) {
            //数字
            return String.valueOf(name.charAt(0));
        }
        p = Pattern.compile("^[a-zA-Z]*");
        m = p.matcher(name);
        if (m.matches()) {
            return String.valueOf(name.charAt(0));
        }
        p = Pattern.compile("[\u4e00-\u9fa5]");
        m = p.matcher(name);
        if (m.matches()) {
            return PinYinUtil.toPinyin(name);
        } else {
            return "";
        }
    }
}
